class Block {
  constructor(id, type, width, height, posX, posY) {
    this.id = id;
    this.type = type;
    this.width = width;
    this.height = height;
    this.x = posX;
    this.y = posY;
  }

  static canMove(board, block, direction, boardWidth, boardHeight) {
    let dx = 0, dy = 0;
    if (direction === 'left') dx = -1;
    else if (direction === 'right') dx = 1;
    else if (direction === 'up') dy = -1;
    else if (direction === 'down') dy = 1;

    for (let i = 0; i < block.width; i++) {
      for (let j = 0; j < block.height; j++) {
        const newX = block.x + dx + i;
        const newY = block.y + dy + j;
        if (newX < 0 || newX >= boardWidth || newY < 0 || newY >= boardHeight) return false;
        if (board[newY][newX] !== 0 && board[newY][newX] !== block.id) return false;
      }
    }
    return true;
  }
}

export default Block;